<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>

<ul class="nav nav-tabs">
	<li class="active"><a href="<?php  echo $this->createWebUrl('waimai',array('op' =>'display'))?>">内容管理</a></li>
	<li<?php  if(empty($adv['id']) && $operation == 'post') { ?> class="active" <?php  } ?>><a href="<?php  echo $this->createWebUrl('waimai',array('op' =>'post'))?>">添加内容</a></li>
</ul>

<?php  if($operation == 'display') { ?>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<form action="" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:10%;">排序</th>
					<th>内容位置</th>
					<th>图片</th>
					<th>标题</th>
					<th>是否显示</th>
					<th style="text-align:right;width:15%;">操作</th>
				</tr>
			</thead>
			<tbody>
				<?php  if(is_array($list)) { foreach($list as $adv) { ?>
				<tr>
					<td><input class="form-control" name="displayorder[<?php  echo $adv['id'];?>]" value="<?php  echo $adv['displayorder'];?>" type="text"></td>
					<td>
						<div><?php  if($adv['cateid']==11) { ?>导航<?php  } ?><?php  if($adv['cateid']==12) { ?>列表<?php  } ?></div>
					</td>
					<td><img src="<?php  echo tomedia($adv['thumb'])?>" height="35px"/></td>
					<td><?php  echo $adv['title'];?></td>
					<td><?php  if($adv['is_show']==1) { ?>是<?php  } else { ?>否<?php  } ?></td>
					<td style="text-align:right;">
					    <a href="<?php  echo $this->createWebUrl('waimai', array('op' => 'show', 'id' => $adv['id']))?>" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="<?php  if($adv['is_show'] == 1) { ?>隐藏<?php  } ?>"><?php  if($adv['is_show'] == 1) { ?>隐藏<?php  } ?><?php  if($adv['is_show'] == 0) { ?>显示<?php  } ?></a>
						<a href="<?php  echo $this->createWebUrl('waimai', array('op' => 'post', 'id' => $adv['id']))?>" class="btn btn-default btn-sm" data-toggle="tooltip" data-placement="top" title="修改"><i class="fa fa-edit"></i></a>
						<a href="<?php  echo $this->createWebUrl('waimai', array('op' => 'delete', 'id' => $adv['id']))?>"class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				<?php  } } ?>
				<tr>
					<td colspan="6">
						<input name="submit" class="btn btn-primary" value="提交" type="submit">
						<input name="token" value="<?php  echo $_W['token'];?>" type="hidden">
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
</div>
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
<?php  } else if($operation == 'post') { ?>

<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data" onsubmit='return formcheck()'>
		<input type="hidden" name="id" value="<?php  echo $adv['id'];?>" />
		<div class="panel panel-default">
			<div class="panel-heading">
				内容设置
			</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[displayorder]" class="form-control" value="<?php  echo $adv['displayorder'];?>" />
						<span class="help-block">降序</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">内容位置：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[cateid]" value="11" <?php  if($adv['cateid'] == 11) { ?>checked="true"<?php  } ?> /> 导航</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[cateid]" value="12" <?php  if($adv['cateid'] == 12) { ?>checked="true"<?php  } ?> /> 红包列表</label>
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否关注公众号才显示：</label>
					<div class="col-sm-9 col-xs-12">
					    <label class="radio-inline"><input type="radio" name="data[is_ios]" value="0" <?php  if($adv['is_ios'] == 0) { ?>checked="true"<?php  } ?><?php  if(!$adv['is_ios']) { ?>checked="true"<?php  } ?> /> 不限制</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_ios]" value="1" <?php  if($adv['is_ios'] == 1) { ?>checked="true"<?php  } ?> /> 关注才显示</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[is_ios]" value="2" <?php  if($adv['is_ios'] == 2) { ?>checked="true"<?php  } ?> /> 没关注才显示</label>
						<span class="help-block" style="color:#f00">是否关注公众号才显示</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否有推荐人才显示：</label>
					<div class="col-sm-9 col-xs-12">
					    <label class="radio-inline"><input type="radio" name="data[elmwm_act_id]" value="0" <?php  if($adv['elmwm_act_id'] == 0) { ?>checked="true"<?php  } ?><?php  if(!$adv['elmwm_act_id']) { ?>checked="true"<?php  } ?> /> 不限制</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[elmwm_act_id]" value="1" <?php  if($adv['elmwm_act_id'] == 1) { ?>checked="true"<?php  } ?> /> 有推荐人才显示</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[elmwm_act_id]" value="2" <?php  if($adv['elmwm_act_id'] == 2) { ?>checked="true"<?php  } ?> /> 没有推荐人才显示</label>
						<span class="help-block" style="color:#f00">是否有推荐人才显示</span>
					</div>
				</div>

				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">标题：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" id='title' name="data[title]" class="form-control" value="<?php  echo $adv['title'];?>" />
					</div>
				</div>
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">内容图片：</label>
					<div class="col-sm-9 col-xs-12">
						<?php  echo tpl_form_field_image('data[thumb]', $adv['thumb'], '', array('extras' => array('text' => 'readonly')))?>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">内容跳转类型：</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="data[adtype]" value="1" <?php  if($adv['adtype'] == 1) { ?>checked="true"<?php  } ?> /> 跳转小程序</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[adtype]" value="2" <?php  if($adv['adtype'] == 2) { ?>checked="true"<?php  } ?> /> 客服回复图片+文字</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[adtype]" value="3" <?php  if($adv['adtype'] == 3) { ?>checked="true"<?php  } ?> /> 客服回复图文链接</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[adtype]" value="4" <?php  if($adv['adtype'] == 4) { ?>checked="true"<?php  } ?> /> 小程序内部链接</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="data[adtype]" value="5" <?php  if($adv['adtype'] == 5) { ?>checked="true"<?php  } ?> /> 网页链接</label>
					</div>
				</div>
				<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">跳转小程序类型：</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="1" <?php  if($adv['appid_type'] == 1) { ?>checked="true"<?php  } ?> /> 美团联盟外卖红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="2" <?php  if($adv['appid_type'] == 2) { ?>checked="true"<?php  } ?> /> 美团联盟闪购红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="5" <?php  if($adv['appid_type'] == 5) { ?>checked="true"<?php  } ?> /> 美团分销联盟吃喝玩乐优惠券</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="6" <?php  if($adv['appid_type'] == 6) { ?>checked="true"<?php  } ?> /> 美团分销联盟外卖红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="7" <?php  if($adv['appid_type'] == 7) { ?>checked="true"<?php  } ?> /> 美团分销联盟闪购红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="8" <?php  if($adv['appid_type'] == 8) { ?>checked="true"<?php  } ?> /> 美团分销联盟酒店红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="3" <?php  if($adv['appid_type'] == 3) { ?>checked="true"<?php  } ?> /> 饿了么外卖红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="4" <?php  if($adv['appid_type'] == 4) { ?>checked="true"<?php  } ?> /> 饿了么果蔬商超红包</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[appid_type]" value="0" <?php  if($adv['appid_type'] == 0) { ?>checked="true"<?php  } ?> /> 跳其他小程序</label>
						</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">美团是否打开二维码图片：</label>
					<div class="col-sm-9 col-xs-12">
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="data[mtpic]" value="1" <?php  if($adv['mtpic'] == 1) { ?>checked="true"<?php  } ?> /> 打开</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[mtpic]" value="0" <?php  if($adv['mtpic'] == 0) { ?>checked="true"<?php  } ?> /> 不打开</label>
						</div>
						<span class="help-block" style="color:red;">*应对美团小程序跳转被封的情况</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">跳转小程序appid：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[appid]" class="form-control" value="<?php  echo $adv['appid'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">跳转小程序path：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[path]" class="form-control" value="<?php  echo $adv['path'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服回复图片：</label>
					<div class="col-sm-9 col-xs-12">
						<?php  echo tpl_form_field_image('data[reply_thumb]', $adv['reply_thumb'], '', array('extras' => array('text' => 'readonly')))?>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服回复文字：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[reply_text]" class="form-control" value="<?php  echo $adv['reply_text'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服回复图文标题：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[link_title]" class="form-control" value="<?php  echo $adv['link_title'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服回复图文描述文字：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[link_desc]" class="form-control" value="<?php  echo $adv['link_desc'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服回复图文图片：</label>
					<div class="col-sm-9 col-xs-12">
						<?php  echo tpl_form_field_image('data[link_thumb]', $adv['link_thumb'], '', array('extras' => array('text' => 'readonly')))?>
						<span class="help-block" style="color:red;">*推荐尺寸200*200</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服回复图文链接：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[link_url]" class="form-control" value="<?php  echo $adv['link_url'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">小程序内部链接或网页链接：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[url]" class="form-control" value="<?php  echo $adv['url'];?>" />
						<span class="help-block" style="color:red;">*小程序内部链接请去参数设置里面查看</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服对话框按钮文字：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[title_text]" class="form-control" value="<?php  echo $adv['title_text'];?>" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">客服对话框提示文字：</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="data[title_desc]" class="form-control" value="<?php  echo $adv['title_desc'];?>" />
					</div>
				</div>
				<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否显示：</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="data[is_show]" value="1" <?php  if($adv['is_show'] == 1) { ?>checked="true"<?php  } ?> /> 显示</label>
							&nbsp;&nbsp;&nbsp;
							<label class="radio-inline"><input type="radio" name="data[is_show]" value="0" <?php  if($adv['is_show'] == 0) { ?>checked="true"<?php  } ?> /> 隐藏</label>
						</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
		</div>
	</form>
</div>

<?php  } ?>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>